changing the name of an excel file

Hi, i am using the below code to change the name an excel file that is obtained after exporting a module in DOORS. As the file is always created under the name Workbook 1, i want to change its name with the module's original name.

Problem is when i execute the program, it performs normally but it gets never inside of the below function. I wonder what may cause this problem. i would appreciate any help greatly, thanks in advance.
 

void createExcelFile(OleAutoObj objExcel, string filename) 
{ 
OleAutoObj objWB 
OleAutoObj objWBs 
OleAutoArgs autoArgs = create 
Module modselektor = current
filename = name(modselektor)
olePut(objExcel,"Visible",true) // Actually i do not need this as my excel is already made visible
oleGet(objExcel,"Workbooks", objWBs) 
put (autoArgs,1) // Create new workbook 
oleMethod(objWBs,"Add",autoArgs,objWB) 
clear autoArgs 
put(autoArgs,filename"") 
oleMethod(objWB,"SaveAs",autoArgs) 
print "i have saved it!"
objWBs = null 
delete autoArgs 
 
if(!null objWB) 
{ 
objWB = null 
return true 
} 
else 
objWB = null 
 
olePut(objExcel,"DisplayAlerts",true) 
}

SystemAdmin - Wed Apr 22 08:04:47 EDT 2009

Re: changing the name of an excel file
SystemAdmin - Wed Apr 22 08:06:47 EDT 2009

Btw i forgot to say that for exporting the module i use the solution of galacatic solution, the one Micheal S. wrote. I do not know if this information can help you but i wanted to share it with you. Thanks again.

Re: changing the name of an excel file
SystemAdmin - Wed Apr 22 09:04:49 EDT 2009

One more little remark, when i use this function without declaring it as a function(i mean when i take off void part), this time i encounter with an error message saying that the OleAutoObj objExcel is not assigned. Thanks

Re: changing the name of an excel file
SystemAdmin - Wed Apr 22 11:22:12 EDT 2009

SystemAdmin - Wed Apr 22 09:04:49 EDT 2009
One more little remark, when i use this function without declaring it as a function(i mean when i take off void part), this time i encounter with an error message saying that the OleAutoObj objExcel is not assigned. Thanks

Hi again i figured out that it would be a little bit difficult for everyone to see what i am doing so i decided to show a part my code where i implemented this algorithme:
 

// Get active workbook
   oleResult( oleGet( objExcelApplication, cExcelPropertyActiveWorkbook, objExcelWorkbook ) )
 
    Module modselektor = current
   string filename = name(modselektor)
   // print "i try to change the file's name with this name\n"   filename "\n"
   OleAutoObj objExcelSheet
   OleAutoArgs AutoArgs = create
   put(AutoArgs,filename "")
 
  oleMethod(objExcelWorkbook,"Name",AutoArgs)
   delete AutoArgs
 
   if ( null objExcelWorkbook ) {
      if ( runInteractive ) errorBox errorCannotGetActiveWorkbook
      return false
   }

 


i do not know if it is clearer right now, but the problem still persists. I do not know why but the active workbook refuses to change its name! :(

 

Re: changing the name of an excel file
SystemAdmin - Fri Apr 24 08:58:56 EDT 2009

SystemAdmin - Wed Apr 22 11:22:12 EDT 2009

Hi again i figured out that it would be a little bit difficult for everyone to see what i am doing so i decided to show a part my code where i implemented this algorithme:
 

// Get active workbook
   oleResult( oleGet( objExcelApplication, cExcelPropertyActiveWorkbook, objExcelWorkbook ) )
 
    Module modselektor = current
   string filename = name(modselektor)
   // print "i try to change the file's name with this name\n"   filename "\n"
   OleAutoObj objExcelSheet
   OleAutoArgs AutoArgs = create
   put(AutoArgs,filename "")
 
  oleMethod(objExcelWorkbook,"Name",AutoArgs)
   delete AutoArgs
 
   if ( null objExcelWorkbook ) {
      if ( runInteractive ) errorBox errorCannotGetActiveWorkbook
      return false
   }

 


i do not know if it is clearer right now, but the problem still persists. I do not know why but the active workbook refuses to change its name! :(

 

Hi again, i found the answer. thanks.

Re: changing the name of an excel file
patrickc3000 - Mon Mar 21 17:54:31 EDT 2011

SystemAdmin - Fri Apr 24 08:58:56 EDT 2009
Hi again, i found the answer. thanks.

Hi,

I have the same issue. What did you do to name an excel file that had been exported?

Re: changing the name of an excel file
Mathias Mamsch - Tue Mar 22 05:31:13 EDT 2011

patrickc3000 - Mon Mar 21 17:54:31 EDT 2011
Hi,

I have the same issue. What did you do to name an excel file that had been exported?

He probably did a SaveAs (...) ;-) How else would you change the filename of an excel file?

See here

Regards, Mathias

Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS